import time
from selenium.webdriver.support.ui import WebDriverWait
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select

class Base():
    def __init__(self,driver):
        self.driver=driver
        self.driver=webdriver.Edge()
    def goto(self,url):
        self.driver.get(url)
    def find_element(self,loc):
        try:
            WebDriverWait(self.driver,20,0.5).until(lambda driver: driver.find_element(*loc).is_playdised)
            return self.driver.find_element(*loc)
        except Exception as e:
            print(e)
    def click(self,loc):
        self.find_element(loc).click()
    def send_keys(self,loc,text):
        self.find_element(loc).send_keys(text)
    def text(self,loc):
        return self.find_element(loc).text
    def sleep(self,timeout):
        time.sleep(int(timeout))
    def kj(self):
        self.driver.switch_to.frame()
    def tkj(self):
        self.driver.switch_to.default_content()
    def gd(self):
        self.driver.execute_script('window.scrollTo(0,1000)')
    def qh(self):
        self.driver.switch_to.window(self.driver.window_handles[-1])
    def shubiao(self):
        ActionChains(self.driver).double_click().perform()
    def kenter(self,loc):
        self.send_keys(loc,Keys.ENTER)
    def shux(self):
        self.driver.refresh()
    def xlk(self,loc,x):
        select=Select(self.driver.find_element(loc))
        select.select_by_value(x)
    def tank(self):
        action=self.driver.switch_to.alert
        action.accept()
